var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  console.log (req.url);
  res.render('index', { title: 'Express' });
});

router.get('/book', function(req, res, next) {
  res.status(404).json({
    statusCode: 404,
    msg: 'Not Found'
  })
});

router.get('/book/:userId/:id', function(req, res, next) {
  res.send(req.params);
});


router.post('/abc', function(req, res, next) {
  console.log (req.body);
  res.send(req.cookies);
});


router.get('/car', function(req, res, next){
  // 打印日志，方便查看
  console.log ('这里是中间件');
  // 继续下一步，下一个中间件
  next();
}, function(req, res, next) {
  // 向页面发送数据
  res.send('这里是返回');
});

module.exports = router;
